package com.boot.mall.product.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.common.utils.PageUtils;
import com.boot.common.utils.Query;

import com.boot.mall.product.dao.BrandDao;
import com.boot.mall.product.entity.BrandEntity;
import com.boot.mall.product.service.BrandService;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    // 分页查询数据
    @Override
    public PageUtils pageBrand(Map<String, Object> params) {
        // 获取参数
        String curr = (String) params.get("page");
        long current = 1;
        if (curr != null) {
            current = Integer.parseInt(curr);
        }
        long limit = 1;
        String limitStr = (String) params.get("limit");
        if (limitStr != null) {
            limit = Integer.parseInt(limitStr);
        }
        // 创建分页对象
        Page<BrandEntity> page = new Page<>(current,limit);
        // 执行查询
        baseMapper.selectPage(page,null);
        // 结果封装
        PageUtils pageUtils = new PageUtils(page.getRecords(),(int)page.getTotal(),(int)page.getSize(),(int)current);
        return pageUtils;
    }
}